<?php
class Rand_nodes extends Widget
{

	function run() {
    	$data = array();
    	$this->ci->load->model("Node_Model", "Nodes");
    	
    	$cache_time = intval($this->ci->settings->item("_site_cache_nodes_time"));
		
    	$node_params = array(
			"order" 	=> "rand",
    		"offset"	=> 5
		);
    	$nodes = $this->ci->mp_cache->model("Nodes", "get", array($node_params), $cache_time);
		
		$nodes_process = array();
		
		foreach($nodes as $node){
			$node->categories = $this->ci->mp_cache->model("Nodes", "getCategories", array($node->id), $cache_time);
			$node->metas = $this->mp_cache->model("Nodes", "getMeta", array($node->id), $cache_time);
			$node->hits = $this->mp_cache->model("Nodes", "getActualHits", array($node->id), $cache_time);		
			
			array_push($nodes_process, $node);
		}
		
		$data['nodes'] = $nodes_process;
		
    			
		$this->template->load_clear("widgets/rand_nodes", $data);
        //$this->render('top_visits_total', $data);
    }
} 
?>